package com.jerry.base.io.write;

import org.junit.Test;

import java.io.*;
import java.nio.charset.Charset;

/**
 * Created with IntelliJ IDEA
 * User: Jerry
 * Date: 2024/1/27
 * Time: 18:50
 * Description:
 */
public class OutputStreamWriterUsage {

    @Test
    public void write() throws IOException {
        String filePath = "src/main/resources/io/charset_write.txt";
        String text = "我要是用GBK编码写入文件中去";

        try (BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(
                new FileOutputStream(filePath), "GBK"))) {
            writer.write(text);
        }
    }
}
